
from sklearn.preprocessing import  MinMaxScaler
import pandas as pd
from sklearn.preprocessing import StandardScaler

def minmax_demo():
    '''
    归一化
    :return:
    '''
    # 1.获取数据
    # 2.实例化一个转换器类
    # 3. 调用 fit_transform
    data=pd.read_csv('dating.txt')
    data=data.iloc[:,:3]#所有行、前三列
    transfer=MinMaxScaler(feature_range=[0,1])
    data_new=transfer.fit_transform(data)
    print(data_new)

def stand_demo():
    '''
    标准化
    :return:
    '''
    # 1.获取数据
    # 2.实例化一个转换器类
    # 3. 调用 fit_transform
    data=pd.read_csv('dating.txt')
    data=data.iloc[:,:3]#所有行、前三列
    transfer=StandardScaler()
    data_new=transfer.fit_transform(data)
    print(data_new)

if __name__=="__main__":
    # minmax_demo()
    stand_demo()